<template>
	<view>
		<view class="main-contain">
			<view class="top-header">
				<view class="welcome-text">
					<text>你好！</text>
					<text>陈校长</text>
				</view>
				<u-avatar :src="avatarSrc" size="60" class="avatar"></u-avatar>
			</view>
			<!-- 学生列表模块 -->
			<view class="student-list-contain">
				<!-- 搜索框 -->
				<view class="search-contain">
					<view class="search-label">
						<span>在校老师</span>
					</view>
					<view class="search-input">
						<u-search v-model="searchVal" :clearabled="false" :show-action="false" :show-icon="false"
							searchIconColor="black" borderColor="black" placeholder="请输入教师姓名" @clickIcon="searChange">
							<template #suffix>
								<view class="custom-search-icon" >
									<u-icon name="search" size="22" color="#909399"></u-icon>
								</view>
							</template></u-search>
					</view>
				</view>
				<!-- 学生列表 -->
				<view class="student-list">
					<view class="studnet-table">
						<view class="table-header">
							<span class="name-item">教师名</span>
							<span class="phone-item">联系电话</span>
							<span class="edit-item">任教科目</span>
						</view>
						<view class="table-th" v-for="(item,index) in filtereList" :key="index">
							<span class="th-name">{{item.name}}</span>
							<span class="th-phone">{{item.phone}}</span>
							<span class="th-edit">
								<u-button type="primary" text="查看" color="#4B71FF"
									customStyle="height:60rpx" @click="goToUploadEdit"></u-button>
							</span>
						</view>
					</view>
				</view>
			</view>
		</view>
			
		<tabBar></tabBar>
	</view>
</template>

<script>
	import { getTeacher } from '@/api/teacherlist.js'

	export default {
		data() {
			return {
				stuName:'',
				campusId:1,
				avatarSrc: "cloud://cloud1-6gveko5wef73d76d.636c-cloud1-6gveko5wef73d76d-1363348768/img/avatar1.png",
				selectVal: '',
				selectShow: false,
				claList: [],
				searchVal: 	'',
				teaList: [],
				filtereList: [], //老师查询
			}
		},
		created() {
			this.filtereList = this.stuList;
		},
		mounted() {
			this.getTeacherList()
		},
		methods: {
			searChange() {
				console.log(this.searchVal);
				const data = {
					campusId: this.campusId,
					nickName:this.searchVal
				}
				getTeacher(data).then(res => {
					this.filtereList = res.data.teacherList.map(item =>{
						return {
							name: item.nickName,
							phone: item.phoneNumber,
						}
					})
				});
				this.filtereList = this.stuList.filter(item => item.name.includes(e))
			},
			getTeacherList() {
				const data = {
					campusId: this.campusId,
				}
				console.log(data,"ID是个啥")
				getTeacher(data).then(res => {
					console.log(res,"xixi")
					this.filtereList = res.data.teacherList.map(item =>{
						return {
							name: item.nickName,
							phone: item.phoneNumber,
						}
					})
				});
			},
		}
	}
</script>

<style lang="scss" scoped>
	.main-contain {
		padding-bottom: 80px;
		box-sizing: border-box;
		.top-header {
			width: 100%;
			height: 90px;
			background-color: #2C57F6;
			display: flex;
			justify-content: center;
			align-items: center;
			padding: 0 24px;
			position: relative;
			
			.welcome-text {
				display: flex;
				gap: 4px;
				color: #fff;
				font-size: 20px;
				// margin-left: 30px;
				margin-right: 70rpx;
			}
			
			.avatar {
				background: #fff;
				border-radius: 50%;
				position: absolute;
				margin-left: 10rpx;
				left: 40px;
			}
		}

		.student-list-contain {
			padding-bottom: 10rpx;
			width: 100%;
			border-radius: 12px;
			border: 1px solid #a6a6a6;

			.search-contain {
				width: 100%;
				height: 120rpx;
				display: inline-flex;

				.search-label {
					width: 40%;
					height: 100%;
					color: #BD3124;
					display: flex;
					justify-content: center;
					align-items: center;
					font-size: 26px;
					font-style: italic;
					font-family: 'PingFang SC-regular', sans-serif;
				}

				.search-input {
					width: 60%;
					height: 100%;
					display: flex;
					box-sizing: border-box;
					align-items: center;
					padding-right: 10%;


					::v-deep .u-search__content {
						flex-direction: row-reverse;
						background: #fff;
						border-radius: 40rpx;
						padding: 0 20rpx;

						.u-content__left-icon {
							margin-left: 10rpx;
							margin-right: 0;
						}

						.u-content__input {
							padding-right: 10rpx;
						}
					}

					.custom-search-icon {
						display: flex;
						align-items: center;
					}
				}
			}

			.student-list {
				width: 100%;
				box-sizing: border-box;
				padding: 0 8%;


				.studnet-table {
					width: 100%;
					height: 100%;
					background-color: #F7F7F7;

					.table-header {
						width: 100%;
						height: 80rpx;
						font-size: 32rpx;
						padding-top: 1%;
						line-height: 80rpx;
						box-sizing: border-box;
						margin-bottom: 20rpx;
						text-align: center;
						color: #101010;
						font-family: 'PingFang SC-regular', sans-serif;

						.name-item,
						.edit-item {
							width: 25%;
							height: 100%;

							display: inline-block;
							overflow: hidden;

						}

						.phone-item {
							width: 50%;
							height: 100%;

							display: inline-block;
							overflow: hidden;
						}
					}

					.table-th {
						width: 100%;
						height: 60rpx;
						line-height: 60rpx;
						text-align: center;
						color: #101010;
						margin-bottom: 20rpx;

						.th-name,
						.th-edit {
							width: 25%;
							height: 100%;

							display: inline-block;
							overflow: hidden;

						}

						.th-phone {
							width: 50%;
							height: 100%;

							display: inline-block;
							overflow: hidden;
						}
					}
				}
			}
		}
	}
</style>